cmake_minimum_required(VERSION 3.10.2)
project("ffmpeg")
include_directories(./include ./decoder ./player)

add_library( # Sets the name of the library.
        native-lib

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        native-lib.cpp
        decoder/AudioDecoder.cpp
        decoder/AVPacketQueue.cpp
        decoder/DecodeResource.cpp
        player/OpenSlPlayer.cpp)

target_include_directories(
        native-lib
        PRIVATE
        ./include
)

find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)

#avcodec-57
add_library(
        avcodec-57
        SHARED
        IMPORTED
)

set_target_properties(
        avcodec-57
        PROPERTIES IMPORTED_LOCATION
        ${CMAKE_SOURCE_DIR}/jniLibs/${ANDROID_ABI}/libavcodec-57.so
)

#avfilter-6
add_library(
        avfilter-6
        SHARED
        IMPORTED
)

set_target_properties(
        avfilter-6
        PROPERTIES IMPORTED_LOCATION
        ${CMAKE_SOURCE_DIR}/jniLibs/${ANDROID_ABI}/libavfilter-6.so
)

#avformat-57
add_library(
        avformat-57
        SHARED
        IMPORTED
)

set_target_properties(
        avformat-57
        PROPERTIES IMPORTED_LOCATION
        ${CMAKE_SOURCE_DIR}/jniLibs/${ANDROID_ABI}/libavformat-57.so
)

#avutil-55
add_library(
        avutil-55
        SHARED
        IMPORTED
)

set_target_properties(
        avutil-55
        PROPERTIES IMPORTED_LOCATION
        ${CMAKE_SOURCE_DIR}/jniLibs/${ANDROID_ABI}/libavutil-55.so
)

#swresample-2
add_library(
        swresample-2
        SHARED
        IMPORTED
)

set_target_properties(
        swresample-2
        PROPERTIES IMPORTED_LOCATION
        ${CMAKE_SOURCE_DIR}/jniLibs/${ANDROID_ABI}/libswresample-2.so
)

#swscale-4
add_library(
        swscale-4
        SHARED
        IMPORTED
)

set_target_properties(
        swscale-4
        PROPERTIES IMPORTED_LOCATION
        ${CMAKE_SOURCE_DIR}/jniLibs/${ANDROID_ABI}/libswscale-4.so
)


target_link_libraries( # Specifies the target library.
        native-lib

        avcodec-57
        avfilter-6
        avformat-57
        avutil-55
        swresample-2
        swscale-4

        OpenSLES

        # Links the target library to the log library
        # included in the NDK.
        ${log-lib})